package com.leyou.page.web;

import com.leyou.page.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

/**
 * @Author: Rose
 * @Date: 2021/4/7 11:06
 * @description ${description}
 * @version: 1.0.0
 */
@Controller
public class HelloController {


    @GetMapping("hello")
    public String toHello(Model model) {

        User user = new User();
        user.setAge(28);
        user.setName("张三");
        user.setFriend(new User("李小龙", 29, null));

        model.addAttribute("msg", "hello Thymeleaf!!1");

        model.addAttribute("user", user);

        // 这个返回的普通字符串会被当成 视图名称, 结合前缀和后缀 寻找视图
        return "hello";
    }
}
